home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
answrbok
/
7_10.lha
/
7_10
/
qt_put.c
< prev
next >
Wrap
Text File
|
1993-08-08
|
1KB
|
52 lines
* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
* The C++ Answer Book */
* Tony Hansen */
* All rights reserved. */
include <process.h>
include <debug.h> /* DELETE */
/ Append object to the rear of the process_queue.
/ If necessary, pause and loop until
/ room becomes available.
nt queue_tail::put(process_object *p)
if (debug) /*DELETE*/ cerr << "queue_tail" << this << "::put()\n";
register process_queue *q = qt_queue;
while (q->q_count >= q->q_max)
switch (qt_mode)
{
case Q_WMODE:
this_process()->pause(this);
break;
case Q_EMODE:
error("queue_head::put(): full queue");
break;
case Q_ZMODE:
if (debug) /*DELETE*/ cerr << "<<<< queue_tail" << this << "::put() <- 0\n";
return 0;
}
if (p->po_next)
error("queue_tail::put(): object on another queue");
// new object on empty queue
if (q->q_count++ == 0)
{
q->q_last = p->po_next = p;
if (q->q_head) q->q_head->alert();
}
// objects are already on the queue
else
{
process_object *last = q->q_last;
p->po_next = last->po_next;
q->q_last = last->po_next = p;
}
if (debug) /*DELETE*/ cerr << "<<<< queue_tail" << this << "::put() <- 1\n";
return 1;